+Fri Oct 5 20:50:00 2001 Jonathan Blandford <jrb@redhat.com>
+
+ * gtk/gtktreestore.c (gtk_tree_store_iter_has_child): improve
+ warning.
+
+ * gtk/gtktreemodel.c (gtk_tree_row_reference_new_proxy): ref and
+ unref nodes, #okay61676
+
+ * gtk/gtktreeviewcolumn.c (gtk_tree_view_column_sort): we listen
+ to the property; no need to clear the other columns. Also, we go
+ to 'unsorted' if the model supports it.
+
2001-10-05 Sven Neumann <sven@gimp.org>
* demos/testpixbuf-save.c
+Fri Oct 5 20:50:00 2001 Jonathan Blandford <jrb@redhat.com>
+
+ * gtk/gtktreestore.c (gtk_tree_store_iter_has_child): improve
+ warning.
+
+ * gtk/gtktreemodel.c (gtk_tree_row_reference_new_proxy): ref and
+ unref nodes, #okay61676
+
+ * gtk/gtktreeviewcolumn.c (gtk_tree_view_column_sort): we listen
+ to the property; no need to clear the other columns. Also, we go
+ to 'unsorted' if the model supports it.
+
2001-10-05 Sven Neumann <sven@gimp.org>
* demos/testpixbuf-save.c
+Fri Oct 5 20:50:00 2001 Jonathan Blandford <jrb@redhat.com>
+
+ * gtk/gtktreestore.c (gtk_tree_store_iter_has_child): improve
+ warning.
+
+ * gtk/gtktreemodel.c (gtk_tree_row_reference_new_proxy): ref and
+ unref nodes, #okay61676
+
+ * gtk/gtktreeviewcolumn.c (gtk_tree_view_column_sort): we listen
+ to the property; no need to clear the other columns. Also, we go
+ to 'unsorted' if the model supports it.
+
2001-10-05 Sven Neumann <sven@gimp.org>
* demos/testpixbuf-save.c
+Fri Oct 5 20:50:00 2001 Jonathan Blandford <jrb@redhat.com>
+
+ * gtk/gtktreestore.c (gtk_tree_store_iter_has_child): improve
+ warning.
+
+ * gtk/gtktreemodel.c (gtk_tree_row_reference_new_proxy): ref and
+ unref nodes, #okay61676
+
+ * gtk/gtktreeviewcolumn.c (gtk_tree_view_column_sort): we listen
+ to the property; no need to clear the other columns. Also, we go
+ to 'unsorted' if the model supports it.
+
2001-10-05 Sven Neumann <sven@gimp.org>
* demos/testpixbuf-save.c
+Fri Oct 5 20:50:00 2001 Jonathan Blandford <jrb@redhat.com>
+
+ * gtk/gtktreestore.c (gtk_tree_store_iter_has_child): improve
+ warning.
+
+ * gtk/gtktreemodel.c (gtk_tree_row_reference_new_proxy): ref and
+ unref nodes, #okay61676
+
+ * gtk/gtktreeviewcolumn.c (gtk_tree_view_column_sort): we listen
+ to the property; no need to clear the other columns. Also, we go
+ to 'unsorted' if the model supports it.
+
2001-10-05 Sven Neumann <sven@gimp.org>
* demos/testpixbuf-save.c
+Fri Oct 5 20:50:00 2001 Jonathan Blandford <jrb@redhat.com>
+
+ * gtk/gtktreestore.c (gtk_tree_store_iter_has_child): improve
+ warning.
+
+ * gtk/gtktreemodel.c (gtk_tree_row_reference_new_proxy): ref and
+ unref nodes, #okay61676
+
+ * gtk/gtktreeviewcolumn.c (gtk_tree_view_column_sort): we listen
+ to the property; no need to clear the other columns. Also, we go
+ to 'unsorted' if the model supports it.
+
2001-10-05 Sven Neumann <sven@gimp.org>
* demos/testpixbuf-save.c
+Fri Oct 5 20:50:00 2001 Jonathan Blandford <jrb@redhat.com>
+
+ * gtk/gtktreestore.c (gtk_tree_store_iter_has_child): improve
+ warning.
+
+ * gtk/gtktreemodel.c (gtk_tree_row_reference_new_proxy): ref and
+ unref nodes, #okay61676
+
+ * gtk/gtktreeviewcolumn.c (gtk_tree_view_column_sort): we listen
+ to the property; no need to clear the other columns. Also, we go
+ to 'unsorted' if the model supports it.
+
2001-10-05 Sven Neumann <sven@gimp.org>
* demos/testpixbuf-save.c
* GtkTreeRowReference
*/
+static void gtk_tree_row_reference_unref_path (GtkTreePath *path,
+ GtkTreeModel *model,
+ gboolean free_last);
+
#define ROW_REF_DATA_STRING "gtk-tree-row-refs"
struct _GtkTreeRowReference
* deletion with the old path of the just-deleted row. Which means
* that the deleted path is the same now-defunct "coordinate system"
* as the path saved in the reference, which is what we want to fix.
- *
- * Note that this is different from the situation in "inserted," so
- * while you might think you can cut-and-paste between these
- * functions, it's not going to work. ;-)
*/
tmp_list = refs->list;
}
else if (gtk_tree_path_compare (path, reference->path) == 0)
{
+ gtk_tree_row_reference_unref_path (reference->path, reference->model, FALSE);
gtk_tree_path_free (reference->path);
reference->path = NULL;
}
model);
}
+
+/* We do this recursively so that we can unref children nodes before their parent */
+static void
+gtk_tree_row_reference_unref_path_helper (GtkTreePath *path,
+ GtkTreeModel *model,
+ GtkTreeIter *parent_iter,
+ gint depth,
+ gboolean free_last)
+{
+ GtkTreeIter iter;
+
+ if (free_last == FALSE && path->depth - 1 == depth)
+ return;
+ if (path->depth == depth)
+ return;
+
+ gtk_tree_model_iter_nth_child (model, &iter, NULL, path->indices[depth]);
+ gtk_tree_row_reference_unref_path_helper (path, model, &iter, depth + 1, free_last);
+ gtk_tree_model_unref_node (model, &iter);
+}
+
+static void
+gtk_tree_row_reference_unref_path (GtkTreePath *path,
+ GtkTreeModel *model,
+ gboolean free_last)
+{
+ GtkTreeIter iter;
+
+ if (free_last == FALSE && path->depth == 1)
+ return;
+
+ gtk_tree_model_iter_nth_child (model, &iter, NULL, path->indices[0]);
+ gtk_tree_row_reference_unref_path_helper (path, model, &iter, 1, free_last);
+ gtk_tree_model_unref_node (model, &iter);
+}
+
static void
disconnect_ref_callbacks (GtkTreeModel *model)
{
NULL);
}
+/**
+ * gtk_tree_row_reference_new:
+ * @model: A #GtkTreeModel
+ * @path: A valid #GtkTreePath
+ *
+ * Creates a row reference based on @path. This reference will keep pointing to
+ * the node pointed to by @path, so long as it exists. It listens to all
+ * signals on model, and updates it's path appropriately. If @path isn't a
+ * valid path in @model, then %NULL is returned.
+ *
+ * Return value: A newly allocated #GtkTreeRowReference, or %NULL
+ **/
GtkTreeRowReference *
gtk_tree_row_reference_new (GtkTreeModel *model,
GtkTreePath *path)
{
GtkTreeRowReference *reference;
RowRefList *refs;
+ GtkTreeIter parent_iter;
+ gint i;
g_return_val_if_fail (G_IS_OBJECT (proxy), NULL);
g_return_val_if_fail (GTK_IS_TREE_MODEL (model), NULL);
g_return_val_if_fail (path != NULL, NULL);
+ g_return_val_if_fail (path->depth > 0, NULL);
+
+ /* check that the path is valid */
+ if (gtk_tree_model_get_iter (model, &parent_iter, path) == FALSE)
+ return NULL;
+
+ /* Now we want to ref every node */
+ gtk_tree_model_iter_nth_child (model, &parent_iter, NULL, path->indices[0]);
+ gtk_tree_model_ref_node (model, &parent_iter);
+
+ for (i = 1; i < path->depth; i++)
+ {
+ GtkTreeIter iter;
+ gtk_tree_model_iter_nth_child (model, &iter, &parent_iter, path->indices[i]);
+ gtk_tree_model_ref_node (model, &iter);
+ parent_iter = iter;
+ }
+ /* Make ther row reference */
reference = g_new (GtkTreeRowReference, 1);
g_object_ref (proxy);
g_object_unref (reference->model);
if (reference->path)
- gtk_tree_path_free (reference->path);
+ {
+ gtk_tree_row_reference_unref_path (reference->path, reference->model, TRUE);
+ gtk_tree_path_free (reference->path);
+ }
g_free (reference);
}
GtkTreeIter *iter)
{
g_return_val_if_fail (GTK_IS_TREE_STORE (tree_model), FALSE);
- g_return_val_if_fail (iter != NULL, FALSE);
+ g_return_val_if_fail (iter->stamp == GTK_TREE_STORE (tree_model)->stamp, FALSE);
g_return_val_if_fail (iter->user_data != NULL, FALSE);
return G_NODE (iter->user_data)->children != NULL;
gtk_tree_view_column_sort (GtkTreeViewColumn *tree_column,
gpointer data)
{
- GList *list;
+ gint sort_column_id;
+ GtkSortType order;
+ gboolean has_sort_column;
+ gboolean has_default_sort_func;
g_return_if_fail (tree_column->tree_view != NULL);
- if (tree_column->show_sort_indicator)
+ has_sort_column =
+ gtk_tree_sortable_get_sort_column_id (GTK_TREE_SORTABLE (GTK_TREE_VIEW (tree_column->tree_view)->priv->model),
+ &sort_column_id,
+ &order);
+ has_default_sort_func =
+ gtk_tree_sortable_has_default_sort_func (GTK_TREE_SORTABLE (GTK_TREE_VIEW (tree_column->tree_view)->priv->model));
+
+ if (has_sort_column &&
+ sort_column_id == tree_column->sort_column_id)
{
- if (tree_column->sort_order == GTK_SORT_ASCENDING)
- gtk_tree_view_column_set_sort_order (tree_column, GTK_SORT_DESCENDING);
+ if (order == GTK_SORT_ASCENDING)
+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (GTK_TREE_VIEW (tree_column->tree_view)->priv->model),
+ tree_column->sort_column_id,
+ GTK_SORT_DESCENDING);
+ else if (order == GTK_SORT_DESCENDING && has_default_sort_func)
+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (GTK_TREE_VIEW (tree_column->tree_view)->priv->model),
+ GTK_TREE_SORTABLE_DEFAULT_SORT_COLUMN_ID,
+ GTK_SORT_ASCENDING);
else
- gtk_tree_view_column_set_sort_order (tree_column, GTK_SORT_ASCENDING);
+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (GTK_TREE_VIEW (tree_column->tree_view)->priv->model),
+ tree_column->sort_column_id,
+ GTK_SORT_ASCENDING);
}
else
{
- gtk_tree_view_column_set_sort_order (tree_column, GTK_SORT_ASCENDING);
- gtk_tree_view_column_set_sort_indicator (tree_column, TRUE);
- }
-
- list = (GTK_TREE_VIEW (tree_column->tree_view)->priv->columns);
- g_assert (list);
- while (list)
- {
- GtkTreeViewColumn *tmp_column;
-
- tmp_column = GTK_TREE_VIEW_COLUMN (list->data);
- if (tmp_column->visible && tmp_column != tree_column)
- gtk_tree_view_column_set_sort_indicator (tmp_column, FALSE);
-
- list = list->next;
+ gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (GTK_TREE_VIEW (tree_column->tree_view)->priv->model),
+ tree_column->sort_column_id,
+ GTK_SORT_ASCENDING);
}
-
- gtk_tree_sortable_set_sort_column_id (GTK_TREE_SORTABLE (GTK_TREE_VIEW (tree_column->tree_view)->priv->model),
- tree_column->sort_column_id,
- tree_column->sort_order);
}
/**
* gtk_tree_view_column_set_alignment:
* @tree_column: A #GtkTreeViewColumn.
- * @xalign: alignment (0.0 for left, 0.5 for center, 1.0 for right)
+ * @xalign: The alignment, which is between [0.0 and 1.0] inclusive.
*
* Sets the alignment of the title or custom widget inside the column header.
+ * The alignment determines its location inside the button -- 0.0 for left, 0.5
+ * for center, 1.0 for right.
**/
void
gtk_tree_view_column_set_alignment (GtkTreeViewColumn *tree_column,